import java.util.concurrent.Callable;

/*
 *Description:
 *User:laoHu
 *Created with Intellij IDEA 2025
 *Data:2025.06.11
 *Time:18:44
 */
//人类
class Person{
    String name;
    int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }
    //....
}
//老师类
class Teacher extends Person{

    public Teacher(String name, int age) {
        super(name, age);
    }
    //....
}
//学生类
class Student extends Person{

    public Student(String name, int age) {
        super(name, age);
    }
    //....
}
//教室类
class Classroom{

    //组合Teacher和Student,创建引用
    private Teacher teacher;
    private  Student student;

    //构造方法
    public Classroom(Teacher teacher, Student student) {
        this.teacher = teacher;
        this.student = student;
    }
    //....
}
class Main1{

    public static void main1(String[] args) {
        //实例化对象
       Classroom classroom = new Classroom(new Teacher("王老师",47),new Student("小李",12));

    }

}

class Base{

    public Base() {
        System.out.println("Base()::构造方法被执行了........1");
    }
    {
        System.out.println("Base()::实例代码块被执行了........2");
    }
    static{
        System.out.println("Base()::静态代码块被执行了........3");
    }
}

class Device extends Base{

    public Device() {
        System.out.println("Device()::构造方法被执行了.........4");
    }
    {
        System.out.println("Device()::实例化代码块被执行了........5");
    }
    static{
        System.out.println("Device()::静态代码块被执行了.........6");
    }

}

//不可继承
final class Test {

    //不可修改
    final int a = 20;
    //a = 10;//err

    final void print(){
        System.out.println(this.a);
    }
    //可以重载
    void print(int a){
        System.out.println(a);
    }
}

//final修饰的不可继承，编译报错
//public class Main extends Test{

  //  @Override
    //不可重写，编译报错
//    void print(){
//        System.out.println("hhhhh");
//    }

//    public static void main1(String[] args) {
//
//        //实例化对象
////      Device device = new Device();
//    }
//}

class A{
    //构造方法
    public A() {
        func();
    }
    void func(){
        System.out.println("A::func()...... " );
    }
}
class B extends A{
    int num = 1;
    public B() {
    }
    @Override
    void func(){
        System.out.println("B::func()执行了......" + num);
    }
}
public class Main {
    public static void main(String[] args) {
        B b = new B();

    }
}
